home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Source Code / Visual Basic Source Code.iso / vbsource / graphics / highlo.frm < prev    next >
Text File  |  1993-05-16  |  2KB  |  71 lines

  1. VERSION 2.00
  2. Begin Form Form1 
  3.    Caption         =   "Daily Highs"
  4.    ClientHeight    =   4260
  5.    ClientLeft      =   1095
  6.    ClientTop       =   1815
  7.    ClientWidth     =   8205
  8.    Height          =   4665
  9.    Left            =   1035
  10.    LinkTopic       =   "Form1"
  11.    ScaleHeight     =   4260
  12.    ScaleWidth      =   8205
  13.    Top             =   1470
  14.    Width           =   8325
  15. End
  16. Option Explicit
  17.  
  18. Const PIXEL = 3
  19.  
  20. Sub Form_Activate ()
  21.     Const MAX_TEMP = 110
  22.     Const MIN_TEMP = -50
  23.  
  24.     Static DailyHighs(31) As Integer
  25.     Dim i As Integer, DaysInMonth As Integer
  26.     Dim fhandle As Integer
  27.     Dim fname As String
  28.     
  29.     i = 1
  30.     fhandle = FreeFile
  31.     fname = "c:\vbdemos\graphics\january.dat"
  32.     Open fname For Input As fhandle
  33.     While Not EOF(fhandle)
  34.         Input #fhandle, DailyHighs(i)
  35.         i = i + 1
  36.     Wend
  37.     Close fhandle
  38.  
  39.     'Now that the number of days in the month can be determined,
  40.     'set the scale mode of the graph accordingly. The graph thus
  41.     'becomes appropriate for charting the temperature.
  42.  
  43.     DaysInMonth = i - 1
  44.     form1.ScaleMode = PIXEL
  45.     Scale (0, MAX_TEMP)-(DaysInMonth + 1, MIN_TEMP)
  46.     
  47.     'Draw a horizontal line representing 0.
  48.     Line (1, 0)-(DaysInMonth + 1, 0)
  49.     
  50.     'Draw the graph.
  51.     For i = 2 To DaysInMonth
  52.         Line (i - 1, DailyHighs(i - 1))-(i, DailyHighs(i))
  53.     Next i
  54.  
  55.     'Print the vertical scale
  56.     For i = MAX_TEMP To MIN_TEMP + 20 Step -10
  57.         currentx = 0
  58.         currenty = i
  59.         Print Trim$(Str$(i))
  60.     Next i
  61.  
  62.     'Print the horizontal scale
  63.     currenty = MIN_TEMP + 10
  64.     For i = 1 To DaysInMonth
  65.         currentx = i
  66.         Print Trim$(Str$(i));
  67.     Next i
  68.         
  69. End Sub
  70.  
  71.